package com.hncc.dms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hncc.dms.domain.DmsMedicinePrescriptionRecord;
import com.hncc.dms.service.IDmsMedicinePrescriptionRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;

/**
 * 成药处方Controller
 * 
 * @author ruoyi
 * @date 2020-09-04
 */
@RestController
@RequestMapping("/dms/medicine_prescription_record")
@Api(tags = "成药处方接口")
public class DmsMedicinePrescriptionRecordController extends BaseController
{
    @Resource
    private IDmsMedicinePrescriptionRecordService dmsMedicinePrescriptionRecordService;

    /**
     * 查询成药处方列表
     */
    @ApiOperation(value = "条件分页查询成药处方",httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('dms:medicine_prescription_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(DmsMedicinePrescriptionRecord dmsMedicinePrescriptionRecord)
    {
        startPage();
        List<DmsMedicinePrescriptionRecord> list = dmsMedicinePrescriptionRecordService.selectDmsMedicinePrescriptionRecordList(dmsMedicinePrescriptionRecord);
        return getDataTable(list);
    }

    /**
     * 缴费|退费 查询成药处方列表
     * @param dmsMedicinePrescriptionRecord
     * @return
     */
    @GetMapping("/getList")
    public AjaxResult getList(DmsMedicinePrescriptionRecord dmsMedicinePrescriptionRecord)
    {
        return AjaxResult.success(dmsMedicinePrescriptionRecordService.selectDmsMedicinePrescriptionRecordGetList(dmsMedicinePrescriptionRecord));
    }
    /**
     * 导出成药处方列表
     */
    @PreAuthorize("@ss.hasPermi('dms:medicine_prescription_record:export')")
    @Log(title = "成药处方", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DmsMedicinePrescriptionRecord dmsMedicinePrescriptionRecord)
    {
        List<DmsMedicinePrescriptionRecord> list = dmsMedicinePrescriptionRecordService.selectDmsMedicinePrescriptionRecordList(dmsMedicinePrescriptionRecord);
        ExcelUtil<DmsMedicinePrescriptionRecord> util = new ExcelUtil<DmsMedicinePrescriptionRecord>(DmsMedicinePrescriptionRecord.class);
        return util.exportExcel(list, "medicine_prescription_record");
    }

    /**
     * 获取成药处方详细信息
     */
    @ApiOperation(value = "根据id获取成药处方详细信息",httpMethod = "GET",
            notes = "根据id查询成药处方")
    @ApiImplicitParam(paramType = "path",name = "id",value = "成药处方id",dataType = "Long",required = true)
    @PreAuthorize("@ss.hasPermi('dms:medicine_prescription_record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dmsMedicinePrescriptionRecordService.selectDmsMedicinePrescriptionRecordById(id));
    }

    /**
     * 新增成药处方
     */
    @ApiOperation(value = "新增",httpMethod = "POST", notes = "新增成药处方")
    @ApiImplicitParam(name = "dmsMedicinePrescriptionRecord", value = "新增成药处方", dataType = "DmsMedicinePrescriptionRecord")
    @PreAuthorize("@ss.hasPermi('dms:medicine_prescription_record:add')")
    @Log(title = "成药处方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsMedicinePrescriptionRecord dmsMedicinePrescriptionRecord)
    {
        return toAjax(dmsMedicinePrescriptionRecordService.insertDmsMedicinePrescriptionRecord(dmsMedicinePrescriptionRecord));
    }

    /**
     * 修改成药处方
     */
    @ApiOperation(value = "修改", httpMethod = "PUT", notes = "修改成药处方")
    @ApiImplicitParam(name = "dmsMedicinePrescriptionRecord", value = "修改成药处方", dataType = "DmsMedicinePrescriptionRecord")
    @PreAuthorize("@ss.hasPermi('dms:medicine_prescription_record:edit')")
    @Log(title = "成药处方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsMedicinePrescriptionRecord dmsMedicinePrescriptionRecord)
    {
        return toAjax(dmsMedicinePrescriptionRecordService.updateDmsMedicinePrescriptionRecord(dmsMedicinePrescriptionRecord));
    }

    /**
     * 删除成药处方
     */
    @ApiOperation(value = "批量删除", httpMethod = "DELETE", notes = "根据ids删除成药处方")
    @ApiImplicitParam(paramType = "path",name = "ids",value = "成药处方id",dataType = "Long[]",required = true)
    @PreAuthorize("@ss.hasPermi('dms:medicine_prescription_record:remove')")
    @Log(title = "成药处方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dmsMedicinePrescriptionRecordService.deleteDmsMedicinePrescriptionRecordByIds(ids));
    }
}
